#include <iostream>
#include <cmath>

using namespace std;

/*
int Fib(int x)
{
    if (x == 0)
        return 0;
    if (x == 1 || x == 2)
        return 1;

    return (Fib(x - 1) + Fib(x - 2));
}

int n;
int _count = 0;

int main()
{
    int _min = 999999;
    cin >> n;

    while (1)
    {
        int ret = Fib(_count++);
        if (abs(ret - n) < _min)
        {
            _min = abs(ret - n);
            int cret = Fib(_count);
            if (abs(cret - n) > _min)
                break;
        }
    }
    cout << _min << endl;
    return 0;
}*/


/*s

int n;

int main()
{
    int a = 0;
    int b = 1;
    int c = 1;
    cin >> n;
    while (n > c)
    {
        a = b;
        b = c;
        c = a + b;

    }
    cout << min(c - n, n - b) << endl;
    return 0; 
}*/